package com.grass.appointment.model;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.grass.appointment.bean.CommentBean;
import com.grass.appointment.bean.CommentContainer;
import com.grass.appointment.bean.ReplyBean;

public class CommentModel extends ViewModel {
    private MutableLiveData<BaseRes<CommentBean>> commentBean;
    private MutableLiveData<BaseRes<CommentContainer>> commentList;
    private MutableLiveData<BaseRes<ReplyBean>> replyBean;

    public MutableLiveData<BaseRes<CommentContainer>> commentList() {
        if (this.commentList == null) {
            this.commentList = new MutableLiveData<>();
        }
        return this.commentList;
    }

    public MutableLiveData<BaseRes<CommentBean>> addComment() {
        if (this.commentBean == null) {
            this.commentBean = new MutableLiveData<>();
        }
        return this.commentBean;
    }

    public MutableLiveData<BaseRes<ReplyBean>> addCommentReply() {
        if (this.replyBean == null) {
            this.replyBean = new MutableLiveData<>();
        }
        return this.replyBean;
    }

    public void loadDynamicComment(int i, long j) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().loadDynamicComment(i, j), new HttpCallback<BaseRes<CommentContainer>>("loadDynamicComment") {
            /* class com.grass.appointment.model.CommentModel.C28331 */

            public void onLvSuccess(BaseRes<CommentContainer> baseRes) {
                CommentModel.this.commentList.setValue(baseRes);
            }
        });
    }

    public void commitComment(int i, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().commitDynamicComment(), JsonParams.build().add("content", str).add("dynamicId", Integer.valueOf(i)).commit(), new HttpCallback<BaseRes<CommentBean>>("commitDynamicComment") {
            /* class com.grass.appointment.model.CommentModel.C28342 */

            public void onLvSuccess(BaseRes<CommentBean> baseRes) {
                CommentModel.this.commentBean.setValue(baseRes);
            }
        });
    }

    public void replyComment(CommentBean commentBean2, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().replyDynamicComment(), JsonParams.build().add("content", str).add("parentId", Integer.valueOf(commentBean2.getCommentId())).add("replyUserId", Integer.valueOf(commentBean2.getUserId())).add("replyUserNickName", commentBean2.getUserNickName()).add("dynamicId", Integer.valueOf(commentBean2.getDynamicId())).commit(), new HttpCallback<BaseRes<ReplyBean>>("replyDynamicComment") {
            /* class com.grass.appointment.model.CommentModel.C28353 */

            public void onLvSuccess(BaseRes<ReplyBean> baseRes) {
                CommentModel.this.replyBean.setValue(baseRes);
            }
        });
    }

    public void replyTwoComment(ReplyBean replyBean2, String str, int i) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().replyDynamicComment(), JsonParams.build().add("content", str).add("parentId", Integer.valueOf(i)).add("replyUserId", Integer.valueOf(replyBean2.getUserId())).add("replyUserNickName", replyBean2.getUserNickName()).add("dynamicId", Integer.valueOf(replyBean2.getDynamicId())).commit(), new HttpCallback<BaseRes<ReplyBean>>("saveComment") {
            /* class com.grass.appointment.model.CommentModel.C28364 */

            public void onLvSuccess(BaseRes<ReplyBean> baseRes) {
                CommentModel.this.replyBean.setValue(baseRes);
            }
        });
    }
}
